package com.example.practical_training_projects.controller;

import com.example.practical_training_projects.entity.appointment;
import com.example.practical_training_projects.entity.articles_class;
import com.example.practical_training_projects.service.articles_classService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("articles_cls")
@CrossOrigin
public class articles_classController {
    @Autowired
    private articles_classService service;
    /**
     *  返回所有类别 http://localhost:8080/articles_cls/list get请求
     * @return
     */
    @GetMapping("list")
    public List<articles_class> getAllclass(){
        List<articles_class> infoList = service.getAllclass();
        return infoList;
    }
    //分页
    @GetMapping("/page")
    public PageInfo<articles_class> getAllclass(Integer pageNum, Integer pageSize){
        PageInfo<articles_class> pageInfo = service.findclasspage(pageNum,pageSize);
        return pageInfo;
    }


    /**
     *  根据主键编号删除文章类别信息 http://localhost:8080/articles_cls/gdel/2 get请求
     * @param
     * @return

    @GetMapping("/del/{id}")
    public Integer deleteclassbyid(@PathVariable("id") Integer as_uid){

        return service.deleteclassbyid(as_uid);
    }
    /**
     *  添加类别 http://localhost:8080/articles_cls/add post请求
     * @param a_cls
     * @return
     */
    @PostMapping("add")
    public Integer addclass(@RequestBody articles_class a_cls){
        return service.insertclass(a_cls);
    }

    /**
     *  修改类别 http:localhost:8080/articles_cls/update post请求
     * @param a_cls
     * @return
     */
    @PostMapping("update")
    public  Integer updateclass(@RequestBody articles_class a_cls){

        return  service.updateclass(a_cls);
    }
}
